﻿namespace HRM.CORE.REPORT
{
    using DevExpress.Utils;
    using DevExpress.XtraBars;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraReports.UI;
    using APP.HELPER;
    using Common.Class; using APP.HELPER.Utils.Language; using Security.Security; using Dictionary.ERP;
    using Common.Report;
    using HRM.CORE;
    using Extra;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms; using Common;

    public class xucOptionPrintSalaryPay : Common.xucBaseOptionPrint
    {
        private ComboBoxEdit cboOrder;
        private CheckEdit cheIsBankSalary;
        private CheckEdit cheShowOrder;
        private IContainer components;
        private DateEdit dtDate;
        private GroupBox groupBox1;
        private LabelControl labelControl1;
        private LabelControl labelControl2;
        private LabelControl labelControl4;
        private string m_Code;
        private int m_Level;
        private int m_Month;
        private int m_Year;
        private xucOrganizationEdit xucOrganizationEdit1;

        public xucOptionPrintSalaryPay()
        {
            this.m_Level = 0;
            this.m_Code = "";
            this.m_Month = 0;
            this.m_Year = 0;
            this.components = null;
            this.InitializeComponent();
        }

        public xucOptionPrintSalaryPay(int Level, string Code)
        {
            this.m_Level = 0;
            this.m_Code = "";
            this.m_Month = 0;
            this.m_Year = 0;
            this.components = null;
            this.InitializeComponent();
            this.m_Level = Level;
            this.m_Code = Code;
            this.xucOrganizationEdit1.LoadData(this.m_Level, this.m_Code);
            this.m_Year = System.DateTime.Now.Year;
            this.m_Month = System.DateTime.Now.Month;
            this.dtDate.DateTime = System.DateTime.Now;
        }

        public xucOptionPrintSalaryPay(int Level, string Code, int Month, int Year)
        {
            this.m_Level = 0;
            this.m_Code = "";
            this.m_Month = 0;
            this.m_Year = 0;
            this.components = null;
            this.InitializeComponent();
            this.m_Level = Level;
            this.m_Code = Code;
            this.xucOrganizationEdit1.LoadData(this.m_Level, this.m_Code);
            System.DateTime time = new System.DateTime(this.m_Year = Year, this.m_Month = Month, 1);
            this.dtDate.DateTime = time;
        }

        protected override void Cancel()
        {
            base.ParentForm.Close();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void dtDate_EditValueChanged(object sender, EventArgs e)
        {
            this.m_Month = this.dtDate.DateTime.Month;
            this.m_Year = this.dtDate.DateTime.Year;
        }

        private void InitializeComponent()
        {
            MenuButton button = new MenuButton();
            ItemCommand command = new ItemCommand();
            ItemCommand command2 = new ItemCommand();
            ItemCommand command3 = new ItemCommand();
            ItemCommand command4 = new ItemCommand();
            ItemCommand command5 = new ItemCommand();
            ItemCommand command6 = new ItemCommand();
            ItemCommand command7 = new ItemCommand();
            ItemCommand command8 = new ItemCommand();
            ItemCommand command9 = new ItemCommand();
            ItemCommand command10 = new ItemCommand();
            ItemCommand command11 = new ItemCommand();
            ItemCommand command12 = new ItemCommand();
            ItemCommand command13 = new ItemCommand();
            ItemCommand command14 = new ItemCommand();
            ItemCommand command15 = new ItemCommand();
            ItemCommand command16 = new ItemCommand();
            ItemCommand command17 = new ItemCommand();
            ItemCommand command18 = new ItemCommand();
            ItemCommand command19 = new ItemCommand();
            ItemCommand command20 = new ItemCommand();
            ItemCommand command21 = new ItemCommand();
            ItemCommand command22 = new ItemCommand();
            ItemCommand command23 = new ItemCommand();
            ItemCommand command24 = new ItemCommand();
            ItemCommand command25 = new ItemCommand();
            ItemCommand command26 = new ItemCommand();
            ItemCommand command27 = new ItemCommand();
            ItemCommand command28 = new ItemCommand();
            ItemCommand command29 = new ItemCommand();
            this.groupBox1 = new GroupBox();
            this.cheIsBankSalary = new CheckEdit();
            this.cheShowOrder = new CheckEdit();
            this.labelControl2 = new LabelControl();
            this.cboOrder = new ComboBoxEdit();
            this.labelControl4 = new LabelControl();
            this.xucOrganizationEdit1 = new xucOrganizationEdit();
            this.labelControl1 = new LabelControl();
            this.dtDate = new DateEdit();
            this.groupBox1.SuspendLayout();
            this.cheIsBankSalary.Properties.BeginInit();
            this.cheShowOrder.Properties.BeginInit();
            this.cboOrder.Properties.BeginInit();
            this.dtDate.Properties.VistaTimeProperties.BeginInit();
            this.dtDate.Properties.BeginInit();
            base.SuspendLayout();
            base.btnPrintPreview.Location = new Point(0x1aa, 0xac);
            base.btnPrint.Location = new Point(0x157, 0xac);
            base.btnCancel.Location = new Point(0xfd, 0xac);
            this.groupBox1.Controls.Add(this.cheIsBankSalary);
            this.groupBox1.Controls.Add(this.cheShowOrder);
            this.groupBox1.Controls.Add(this.labelControl2);
            this.groupBox1.Controls.Add(this.cboOrder);
            this.groupBox1.Controls.Add(this.labelControl4);
            this.groupBox1.Controls.Add(this.xucOrganizationEdit1);
            this.groupBox1.Controls.Add(this.labelControl1);
            this.groupBox1.Controls.Add(this.dtDate);
            this.groupBox1.Location = new Point(12, 4);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new Size(0x1f9, 0x9d);
            this.groupBox1.TabIndex = 0x26;
            this.groupBox1.TabStop = false;
            this.cheIsBankSalary.Location = new Point(12, 0x7d);
            this.cheIsBankSalary.Name = "cheIsBankSalary";
            this.cheIsBankSalary.Properties.Caption = "In danh s\x00e1ch trả lương qua ng\x00e2n h\x00e0ng";
            this.cheIsBankSalary.Size = new Size(0x125, 0x13);
            this.cheIsBankSalary.TabIndex = 0x2c;
            this.cheShowOrder.EditValue = true;
            this.cheShowOrder.Location = new Point(12, 0x60);
            this.cheShowOrder.Name = "cheShowOrder";
            this.cheShowOrder.Properties.Caption = "Hiển thị lần thanh to\x00e1n trong bảng in";
            this.cheShowOrder.Size = new Size(0x125, 0x13);
            this.cheShowOrder.TabIndex = 0x2b;
            this.labelControl2.AllowHtmlString = true;
            this.labelControl2.Location = new Point(0xc9, 0x34);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new Size(0x5e, 14);
            this.labelControl2.TabIndex = 0x2a;
            this.labelControl2.Text = "Lần thanh to\x00e1n <color=blue>(*)</color>:";
            this.cboOrder.EditValue = "1";
            this.cboOrder.Location = new Point(0x12b, 0x31);
            this.cboOrder.Name = "cboOrder";
            this.cboOrder.Properties.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.cboOrder.Properties.Appearance.Options.UseFont = true;
            this.cboOrder.Properties.Appearance.Options.UseTextOptions = true;
            this.cboOrder.Properties.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
            this.cboOrder.Properties.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.cboOrder.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cboOrder.Properties.Items.AddRange(new object[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" });
            this.cboOrder.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;
            this.cboOrder.Size = new Size(100, 20);
            this.cboOrder.TabIndex = 0x29;
            this.labelControl4.Location = new Point(14, 0x12);
            this.labelControl4.Name = "labelControl4";
            this.labelControl4.Size = new Size(0x3d, 13);
            this.labelControl4.TabIndex = 0x27;
            this.labelControl4.Text = "Chọn đơn vị:";
            this.xucOrganizationEdit1.BranchCode = null;
            this.xucOrganizationEdit1.Code = null;
            this.xucOrganizationEdit1.DepartmentCode = null;
            this.xucOrganizationEdit1.EmployeeCode = null;
            this.xucOrganizationEdit1.GroupCode = null;
            this.xucOrganizationEdit1.IsClose = CloseOrNew.None;
            this.xucOrganizationEdit1.Level = 0;
            this.xucOrganizationEdit1.Location = new Point(0x51, 0x10);
            this.xucOrganizationEdit1.Name = "xucOrganizationEdit1";
            this.xucOrganizationEdit1.NotSave = false;
            command.Caption = "";
            command.Enable = false;
            command.Visibility = BarItemVisibility.Never;
            button.Add = command;
            command2.Caption = "";
            command2.Enable = false;
            command2.Visibility = BarItemVisibility.Never;
            button.Cancel = command2;
            command3.Caption = "";
            command3.Enable = false;
            command3.Visibility = BarItemVisibility.Never;
            button.Change = command3;
            command4.Caption = "";
            command4.Enable = false;
            command4.Visibility = BarItemVisibility.Never;
            button.Close = command4;
            command5.Caption = "";
            command5.Enable = false;
            command5.Visibility = BarItemVisibility.Never;
            button.Custom = command5;
            command6.Caption = "";
            command6.Enable = false;
            command6.Visibility = BarItemVisibility.Never;
            button.Delete = command6;
            command7.Caption = "";
            command7.Enable = false;
            command7.Visibility = BarItemVisibility.Never;
            button.Export = command7;
            command8.Caption = "";
            command8.Enable = false;
            command8.Visibility = BarItemVisibility.Never;
            button.Filter = command8;
            command9.Caption = "";
            command9.Enable = false;
            command9.Visibility = BarItemVisibility.Never;
            button.FilterCustomer = command9;
            command10.Caption = "";
            command10.Enable = false;
            command10.Visibility = BarItemVisibility.Never;
            button.FilterStock = command10;
            command11.Caption = "";
            command11.Enable = false;
            command11.Visibility = BarItemVisibility.Never;
            button.Find = command11;
            button.GClose = false;
            button.GCommand = false;
            button.GExport = false;
            command12.Caption = "";
            command12.Enable = false;
            command12.Visibility = BarItemVisibility.Never;
            button.Go = command12;
            button.GOption = false;
            button.GPrint = false;
            button.GRecords = false;
            button.GSearchBar = false;
            button.GSettings = false;
            button.GVaildation = false;
            command13.Caption = "";
            command13.Enable = false;
            command13.Visibility = BarItemVisibility.Never;
            button.Import = command13;
            command14.Caption = "";
            command14.Enable = false;
            command14.Visibility = BarItemVisibility.Never;
            button.Next = command14;
            command15.Caption = "";
            command15.Enable = false;
            command15.Visibility = BarItemVisibility.Never;
            button.PageSetup = command15;
            button.PHome = false;
            command16.Caption = "";
            command16.Enable = false;
            command16.Visibility = BarItemVisibility.Never;
            button.Previous = command16;
            command17.Caption = "";
            command17.Enable = false;
            command17.Visibility = BarItemVisibility.Never;
            button.Print = command17;
            command18.Caption = "";
            command18.Enable = false;
            command18.Visibility = BarItemVisibility.Never;
            button.PrintPreview = command18;
            button.PTool = false;
            command19.Caption = "";
            command19.Enable = false;
            command19.Visibility = BarItemVisibility.Never;
            button.Redo = command19;
            command20.Caption = "";
            command20.Enable = false;
            command20.Visibility = BarItemVisibility.Never;
            button.Refresh = command20;
            command21.Caption = "";
            command21.Enable = false;
            command21.Visibility = BarItemVisibility.Never;
            button.Save = command21;
            command22.Caption = "";
            command22.Enable = false;
            command22.Visibility = BarItemVisibility.Never;
            button.SaveAndClose = command22;
            command23.Caption = "";
            command23.Enable = false;
            command23.Visibility = BarItemVisibility.Never;
            button.SaveAndNew = command23;
            command24.Caption = "";
            command24.Enable = false;
            command24.Visibility = BarItemVisibility.Never;
            button.Search = command24;
            command25.Caption = "";
            command25.Enable = false;
            command25.Visibility = BarItemVisibility.Never;
            button.SearchText = command25;
            command26.Caption = "";
            command26.Enable = false;
            command26.Visibility = BarItemVisibility.Never;
            button.Task = command26;
            command27.Caption = "";
            command27.Enable = false;
            command27.Visibility = BarItemVisibility.Never;
            button.Undo = command27;
            command28.Caption = "";
            command28.Enable = false;
            command28.Visibility = BarItemVisibility.Never;
            button.Vaildate = command28;
            command29.Caption = "";
            command29.Enable = false;
            command29.Visibility = BarItemVisibility.Never;
            button.View = command29;
            this.xucOrganizationEdit1.RibbonBar = button;
            this.xucOrganizationEdit1.Size = new Size(0x199, 0x16);
            this.xucOrganizationEdit1.Status = Actions.None;
            this.xucOrganizationEdit1.TabIndex = 0x26;
            this.xucOrganizationEdit1.Title = "";
            this.labelControl1.Location = new Point(14, 50);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(60, 13);
            this.labelControl1.TabIndex = 13;
            this.labelControl1.Text = "Chọn th\x00e1ng:";
            this.dtDate.EditValue = null;
            this.dtDate.Location = new Point(0x51, 0x30);
            this.dtDate.Name = "dtDate";
            this.dtDate.Properties.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.dtDate.Properties.Appearance.Options.UseFont = true;
            this.dtDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.dtDate.Properties.DisplayFormat.FormatString = "MM/yyyy";
            this.dtDate.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
            this.dtDate.Properties.EditFormat.FormatString = "MM/yyyy";
            this.dtDate.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
            this.dtDate.Properties.Mask.EditMask = "MM/yyyy";
            this.dtDate.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.dtDate.Size = new Size(110, 20);
            this.dtDate.TabIndex = 12;
            this.dtDate.EditValueChanged += new EventHandler(this.dtDate_EditValueChanged);
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.groupBox1);
            base.Name = "xucOptionPrintSalaryPay";
            base.Size = new Size(530, 0xd3);
            base.Controls.SetChildIndex(base.btnPrintPreview, 0);
            base.Controls.SetChildIndex(base.btnPrint, 0);
            base.Controls.SetChildIndex(base.btnCancel, 0);
            base.Controls.SetChildIndex(this.groupBox1, 0);
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.cheIsBankSalary.Properties.EndInit();
            this.cheShowOrder.Properties.EndInit();
            this.cboOrder.Properties.EndInit();
            this.dtDate.Properties.VistaTimeProperties.EndInit();
            this.dtDate.Properties.EndInit();
            base.ResumeLayout(false);
        }

        protected override void Print()
        {
            this.Print(false);
        }

        private void Print(bool IsPrintPreview)
        {
            this.m_Level = this.xucOrganizationEdit1.Level;
            this.m_Code = this.xucOrganizationEdit1.Code;
            XtraReport xtraReport = new XtraReport();
            xfmReport report2 = new xfmReport();
            report2.SetTitle("Bảng Chấm C\x00f4ng Th\x00e1ng " + this.m_Month.ToString() + "/" + this.m_Year.ToString());
            HRM_SALARY_TABLELIST hrm_salary_tablelist = new HRM_SALARY_TABLELIST();
            if (!hrm_salary_tablelist.Exist(this.m_Month, this.m_Year))
            {
                XtraMessageBox.Show("Bảng lương th\x00e1ng n\x00e0y kh\x00f4ng tồn tại trong cơ sở dữ liệu của chương tr\x00ecnh!\nVui l\x00f2ng chọn th\x00e1ng b\x00e1o c\x00e1o kh\x00e1c!", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                if (this.cheIsBankSalary.Checked)
                {
                    xtraReport = new rptSalaryPayBank(this.m_Level, this.m_Code, this.m_Month, this.m_Year, int.Parse(this.cboOrder.EditValue.ToString()), this.cheShowOrder.Checked);
                    report2.SetTitle("Thanh To\x00e1n Lương Th\x00e1ng " + this.m_Month.ToString() + "/" + this.m_Year.ToString());
                }
                else
                {
                    xtraReport = new rptSalaryPay(this.m_Level, this.m_Code, this.m_Month, this.m_Year, int.Parse(this.cboOrder.EditValue.ToString()), this.cheShowOrder.Checked);
                    report2.SetTitle("Thanh To\x00e1n Lương Th\x00e1ng " + this.m_Month.ToString() + "/" + this.m_Year.ToString());
                }
                if (IsPrintPreview)
                {
                    report2.ShowPrintPreview(xtraReport);
                }
                else
                {
                    PrintDialog dialog = new PrintDialog();
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        string printerName = dialog.PrinterSettings.PrinterName;
                        xtraReport.Print(printerName);
                    }
                }
            }
        }

        protected override void PrintPreview()
        {
            this.Print(true);
        }
    }
}

